package com.weiyuwqj.app.mobile.account;

import com.weiyuwqj.api.common.Paginator;
import com.weiyuwqj.api.constant.Message;
//import com.weiyuwqj.api.hengfeng.model.base.HfResultBean;
//import com.weiyuwqj.api.hengfeng.model.recharge.HfQuickRechargeRequestByShop;
import com.weiyuwqj.api.model.BasUser;
import com.weiyuwqj.api.service.BasUserService;
import com.weiyuwqj.api.service.BusAccountCashService;
import com.weiyuwqj.api.service.BusAccountRechargeService;
import com.weiyuwqj.api.util.IpUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.logging.Logger;

/**
 * Created by Administrator on 2016/1/8.
 */
@Controller
public class MobileAccountRechargeController {

    private static Logger log = Logger.getLogger("MobileAccountRechargeController");

    @Autowired
    private BusAccountRechargeService accountRechargeService;

    @Autowired
    private BasUserService userService;

	@Autowired
	private BusAccountCashService accountCashService;

//    /**
//     * 充值
//     *
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping(value = "/mobile/account/recharge")
//    public Object recharge(String orderId, Integer status, String userId, String amount) {
//        log.info("recharge-------orderNo:" + orderId + "------status:" + status);
//
//        BasUser basUser = userService.selectByKey(userId);
//        HfQuickRechargeRequestByShop quickRechargeRequestByShop = new HfQuickRechargeRequestByShop();
//        quickRechargeRequestByShop.setOrder_no(orderId);                        // 订单ID
//        quickRechargeRequestByShop.setPlatcust(basUser.getPlatformId());        // 用户编号
//        quickRechargeRequestByShop.setAmt(amount); // 充值金额
//        if (Integer.valueOf(1).equals(basUser.getType()) || Integer.valueOf(4).equals(basUser.getType())) {
//            quickRechargeRequestByShop.setCharge_type("1");
//        } else if (Integer.valueOf(2).equals(basUser.getType()) || Integer.valueOf(3).equals(basUser.getType())) {
//            quickRechargeRequestByShop.setCharge_type("2");
//        }
//        //quickRechargeRequestByShop.setReturn_url(); // 同步回调地址
//        //quickRechargeRequestByShop.setNotify_url(); // 异步通知地址
//	    HfResultBean bean = accountCashService.quickRecharegeByShop(quickRechargeRequestByShop);
//	    accountRechargeService.updateBusAccountRechargeStatus(orderId, 2, status, IpUtils.get());
//	    if (bean.isSuccess()) {
//		    return Message.OK;
//	    } else {
//		    return Message.FAIL;
//	    }
//    }

    //根据userId获取充值列表
    @ResponseBody
    @RequestMapping(value = "/mobile/account/getRechargeListByUserId")
    public Object getRechargeListByUserId(Paginator p, Integer userId) {
        return accountRechargeService.getListByUserId(p, userId);
    }


}
